<template>
  <div style="margin-top:30px">
    <el-form ref="form" :model="form" label-width="80px" :rules="rules">
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="入驻商" style="margin-right:15px" prop="shipmentCode">
              <el-input v-model="form.shipmentName" style="width:100%" :disabled="true"/>
              <!-- <shipmentSelect ref="shipmentSelect" :defaultValue="form.shipmentCode" url="/wms/warehouseShipment/business/shipments" @setShipmentCode="setShipmentCode" style="width: 100%"/> -->
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="品牌编码" style="margin-right:15px" prop="brandNumber">
              <el-input v-model="form.brandNumber" placeholder="请输入品牌编码" style="width:100%"   maxlength="100"  show-word-limit/>
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="品牌名称" style="margin-right:15px" prop="name">
              <el-input v-model="form.name" placeholder="请输入品牌名称" style="width:100%"    maxlength="100"  show-word-limit/>
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="备注" style="margin-right:15px">
              <el-input v-model="form.remarks" placeholder="请输入备注" style="width:100%"   maxlength="100"  show-word-limit/>
            </el-form-item>
          </div>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="funcSubmit"  :disabled="isDisable" plain>确 定</el-button>
    </div>
  </div>
</template>
<script>
import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import { brandEdit,brandDetail} from '@/api/basicInfo'
import shipmentSelect from '@/views/components/shipmentSelect.vue'
Vue.use(VXETable)
export default {
  components: {
    shipmentSelect
  },
  props: {
    operationCode: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      isDisable:false,   //确定键显示按钮

      form: {
        brandNumber:'',               //品牌编码 ,
        code:'',                      //数据标识 ,
        name:'',                      //名称 ,
        remarks:'',                   //备注 ,
        shipmentCode:'',              //所属入驻商 ,
      },
        rules: {
          brandNumber: [
            {required: true, message: '请输入品牌编码', trigger: 'blur'},
          ],
          name: [
            {required: true, message: '请输入品牌名称', trigger: 'blur'},
          ],
          shipmentCode: [
            {required: true, message: '请选择所属入驻商', trigger: 'blur'},
          ],
        },
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    setShipmentCode(value) {
      this.form.shipmentCode = value
    },
    // 获取页面信息
    getInfo() {
      brandDetail(this.operationCode).then(response => {
        this.form = response.data

        this.$refs.shipmentSelect.setSelectValue(this.form.shipmentCode);
      })
    },
    // 提交
    funcSubmit() {
      const data = this.form
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.isDisable = true;
          brandEdit(data).then(response => {
            this.$message({ message: response.msg, type: 'success' })
            this.$emit('fatherEditMethod')
            this.isDisable = false
          }).catch(() => this.isDisable = false)
        } else {
          return false
        }
      })

    },

    // 取消
    funcCancel() {
      this.$emit('fatherCancelMethod', 'edit')
    }

  }
}
</script>
<style lang="scss" scoped >
  .dialog-footer {
    margin: 15px 0 15px 0;
    width: 90px;
    float: right;
  }
</style>
